# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=libmaxminddb
pkgver=1.9.1
pkgrel=0
pkgdesc="Maxmind GeoIP2 database library"
url="https://github.com/maxmind/libmaxminddb"
arch="all"
license="Apache-2.0"
depends="curl"
checkdepends="perl"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs"
install="libmaxminddb.post-upgrade"
source="https://github.com/maxmind/libmaxminddb/releases/download/$pkgver/libmaxminddb-$pkgver.tar.gz
	libmaxminddb.cron
	libmaxminddb.confd
	"

# secfixes:
#   1.4.3-r0:
#     - CVE-2020-28241

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-pic
	make
}

check() {
	make check
}

package() {
	make install DESTDIR="$pkgdir"

	# install alpine specifics
	mkdir -p "$pkgdir"/var/lib/libmaxminddb
	install -Dm755 "$srcdir"/libmaxminddb.cron "$pkgdir"/etc/periodic/weekly/libmaxminddb

	# Not an openrc config file. See cron script.
	install -Dm644 "$srcdir"/libmaxminddb.confd "$pkgdir"/etc/libmaxminddb.cron.conf
}

sha512sums="
6da76bb584c5f8a0c01eb9439afd7c4b18b765966591c15e9aaf6ce7edfd3c429cff87a3e7481eff1d3e75df6eb7fd484752946417747c193dbfb277a843810c  libmaxminddb-1.9.1.tar.gz
ca1d60847b20a477e91e14ae27d6bbe5d34ddc328e39387eaf9376c72e7f3b4418a932e007fc5b018f0f40e28761dca2a0e9c78f6cf423049f959a075fcaa34f  libmaxminddb.cron
d7a9614d7420c2ffff9f789d5086002a84a1e9d6dd1dc014d8f792e0e4bd47f7d4794991b786005b8d5539815b305cfc768058c8b4ed49cad542e74e095971a7  libmaxminddb.confd
"
